<?php
	include "../public/commom/config.php";
	include "../public/commom/commom.php";
	
	if($_POST) {
		$username = $_POST["username"];
		$password = $_POST["password"];
		
		if($username == "admin") {
			$password = MD5($_POST["password"]);
		}
		
		$sql = "SELECT * FROM user WHERE username = '$username'";
		
		$result = mysqli_query($conn, $sql);
	    
	    if(mysqli_num_rows($result)) {
	    	while($row = mysqli_fetch_array($result)) {
	    		$pass = $row["password"];
	    		
	    		if($password == $pass) {
	    			$_SESSION["user_id"] = $row["id"];
	    			$_SESSION["username"] = $row["username"];
	    			$_SESSION["rule"] = $row["rule"];
	    			
	    			mysqli_close($conn);
	    			
		    		header("Location: ./personal.php");
		    	} else {
		    		echo "密码错误";
		    	}
	    	}
	    } else{
	    	echo "用户名不存在";
	    }
	}
?>

<!DOCTYPE html>
<html>
	
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	
	<body>
		
	</body>
	
</html>